using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace Decision.BusinessLayer.DataLayer
{
	/// <summary>
	/// Data access layer class for DCS_MASTER
	/// </summary>
	class DCS_MASTERSql : DataLayerBase 
	{

        #region Constructor

		/// <summary>
		/// Class constructor
		/// </summary>
		public DCS_MASTERSql()
		{
			// Nothing for now.
		}

        #endregion

        #region Public Methods

        /// <summary>
        /// insert new row in the table
        /// </summary>
		/// <param name="businessObject">business object</param>
		/// <returns>true of successfully insert</returns>
		public bool Insert(DCS_MASTER businessObject)
		{
			SqlCommand	sqlCommand = new SqlCommand();
			sqlCommand.CommandText = "dbo.[DCS_MASTER_Insert]";
			sqlCommand.CommandType = CommandType.StoredProcedure;

			// Use connection object of base class
			sqlCommand.Connection = MainConnection;

			try
			{
                
				sqlCommand.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MASTER_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@CASE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@NOTICE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NOTICE));
				sqlCommand.Parameters.Add(new SqlParameter("@CODE_NO", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CODE_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@CREATE_DECISION_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATE_DECISION_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_CASE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_CASE));
				sqlCommand.Parameters.Add(new SqlParameter("@COUNTY_NO", SqlDbType.NVarChar, 3, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@COUNTY", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY));
				sqlCommand.Parameters.Add(new SqlParameter("@AUMPHER", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.AUMPHER));
				sqlCommand.Parameters.Add(new SqlParameter("@TUMBON", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TUMBON));
				sqlCommand.Parameters.Add(new SqlParameter("@PROVINCE", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.PROVINCE));
				sqlCommand.Parameters.Add(new SqlParameter("@TERM_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TERM_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@DECISION_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@CASE_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_TYPE));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_B_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_B_SUPREME_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_A_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_A_SUPREME_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_CONSTITU_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_CONSTITU_TYPE));
				sqlCommand.Parameters.Add(new SqlParameter("@SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.SIGN_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@WARN_SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_SIGN_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@WARN_RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_RESULT_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@REQUEST_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REQUEST_NAME));
				sqlCommand.Parameters.Add(new SqlParameter("@RESPON_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESPON_NAME));
				sqlCommand.Parameters.Add(new SqlParameter("@ALLEGATION", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ALLEGATION));
				sqlCommand.Parameters.Add(new SqlParameter("@LAWYER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.LAWYER_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@STATUS", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.STATUS));
                sqlCommand.Parameters.Add(new SqlParameter("@REMARK", SqlDbType.Text, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REMARK));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_APPEALS_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_APPEALS_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@DECISION_TYPE_ETC", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_TYPE_ETC));								

				MainConnection.Open();
				
				sqlCommand.ExecuteNonQuery();
                businessObject.MASTER_ID = (int)sqlCommand.Parameters["@MASTER_ID"].Value;

				return true;
			}
			catch(Exception ex)
			{				
				throw new Exception("DCS_MASTER::Insert::Error occured."+ex.ToString(), ex);
			}
			finally
			{			
				MainConnection.Close();
				sqlCommand.Dispose();
			}
		}

        /// <summary>
        /// insert new row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true of successfully insert</returns>
        public bool InsertDcsMasterTransaction(DCS_MASTER businessObject, List<TBL_DCS_MASTER_DECISION_TYPE> listBusinessObject1)
        {
            SqlCommand sqlCommand = new SqlCommand();
            MainConnection.Open();
            SqlTransaction transaction = transaction = MainConnection.BeginTransaction();

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.CommandText = "dbo.[DCS_MASTER_Insert]";
                sqlCommand.CommandType = CommandType.StoredProcedure;

                sqlCommand.Connection = MainConnection;
                sqlCommand.Transaction = transaction;

                sqlCommand.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MASTER_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@CASE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_TYPE_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@NOTICE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NOTICE));
                sqlCommand.Parameters.Add(new SqlParameter("@CODE_NO", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CODE_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATE_DECISION_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATE_DECISION_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@VOTE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_TYPE_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@VOTE_CASE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_CASE));
                sqlCommand.Parameters.Add(new SqlParameter("@COUNTY_NO", SqlDbType.NVarChar, 3, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@COUNTY", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY));
                sqlCommand.Parameters.Add(new SqlParameter("@AUMPHER", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.AUMPHER));
                sqlCommand.Parameters.Add(new SqlParameter("@TUMBON", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TUMBON));
                sqlCommand.Parameters.Add(new SqlParameter("@PROVINCE", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.PROVINCE));
                sqlCommand.Parameters.Add(new SqlParameter("@TERM_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TERM_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@DECISION_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@CASE_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@RESULT_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_NO));
                sqlCommand.Parameters.Add(new SqlParameter("@RESULT_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_TYPE));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_TYPE_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_B_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_B_SUPREME_TYPE_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_A_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_A_SUPREME_TYPE_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_CONSTITU_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_CONSTITU_TYPE));
                sqlCommand.Parameters.Add(new SqlParameter("@SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.SIGN_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@WARN_SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_SIGN_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@VOTE_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@WARN_RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_RESULT_DATE));
                sqlCommand.Parameters.Add(new SqlParameter("@REQUEST_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REQUEST_NAME));
                sqlCommand.Parameters.Add(new SqlParameter("@RESPON_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESPON_NAME));
                sqlCommand.Parameters.Add(new SqlParameter("@ALLEGATION", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ALLEGATION));
                sqlCommand.Parameters.Add(new SqlParameter("@LAWYER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.LAWYER_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@STATUS", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.STATUS));
                sqlCommand.Parameters.Add(new SqlParameter("@REMARK", SqlDbType.Text, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REMARK));
                sqlCommand.Parameters.Add(new SqlParameter("@DECISION_TYPE_ETC", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_TYPE_ETC));


                sqlCommand.ExecuteNonQuery();
                businessObject.MASTER_ID = (int)sqlCommand.Parameters["@MASTER_ID"].Value;

                foreach (TBL_DCS_MASTER_DECISION_TYPE businessObject1 in listBusinessObject1)
                {
                    SqlCommand sqlCommandDecision = new SqlCommand();
                    sqlCommandDecision.CommandText = "dbo.[DCS_MASTER_DECISION_TYPE_Insert]";
                    sqlCommandDecision.CommandType = CommandType.StoredProcedure;

                    // Use connection object of base class
                    sqlCommandDecision.Connection = MainConnection;
                    sqlCommandDecision.Transaction = transaction;

                    sqlCommandDecision.Parameters.Add(new SqlParameter("@DCS_MASTER_DECISION_ID", SqlDbType.Int, 4, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject1.DCS_MASTER_DECISION_ID));
                    sqlCommandDecision.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MASTER_ID));
                    sqlCommandDecision.Parameters.Add(new SqlParameter("@DECISION_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject1.DECISION_TYPE_ID));

                    sqlCommandDecision.ExecuteNonQuery();
                    businessObject1.DCS_MASTER_DECISION_ID = (int)sqlCommandDecision.Parameters["@DCS_MASTER_DECISION_ID"].Value;
                }

                //Commit
                transaction.Commit();

                return true;
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw new Exception("DCS_MASTER::Insert::Error occured." + ex.ToString(), ex);
            }
            finally
            {
                transaction.Dispose();
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }

         /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(DCS_MASTER businessObject)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_Update]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
				sqlCommand.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MASTER_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@CASE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@NOTICE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.NOTICE));
				sqlCommand.Parameters.Add(new SqlParameter("@CODE_NO", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CODE_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@CREATE_DECISION_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATE_DECISION_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_CASE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_CASE));
				sqlCommand.Parameters.Add(new SqlParameter("@COUNTY_NO", SqlDbType.NVarChar, 3, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@COUNTY", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COUNTY));
				sqlCommand.Parameters.Add(new SqlParameter("@AUMPHER", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.AUMPHER));
				sqlCommand.Parameters.Add(new SqlParameter("@TUMBON", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TUMBON));
				sqlCommand.Parameters.Add(new SqlParameter("@PROVINCE", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.PROVINCE));
				sqlCommand.Parameters.Add(new SqlParameter("@TERM_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TERM_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@DECISION_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@CASE_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CASE_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_NO", SqlDbType.NVarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_NO));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_TYPE));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_B_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_B_SUPREME_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_A_SUPREME_TYPE_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_A_SUPREME_TYPE_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@COURT_CONSTITU_TYPE", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_CONSTITU_TYPE));
				sqlCommand.Parameters.Add(new SqlParameter("@SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.SIGN_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@WARN_SIGN_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_SIGN_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@VOTE_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.VOTE_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESULT_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@WARN_RESULT_DATE", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.WARN_RESULT_DATE));
				sqlCommand.Parameters.Add(new SqlParameter("@REQUEST_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REQUEST_NAME));
				sqlCommand.Parameters.Add(new SqlParameter("@RESPON_NAME", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.RESPON_NAME));
				sqlCommand.Parameters.Add(new SqlParameter("@ALLEGATION", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ALLEGATION));
				sqlCommand.Parameters.Add(new SqlParameter("@LAWYER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.LAWYER_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@CREATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.CREATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_DATE_TIME", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_DATE_TIME));
                sqlCommand.Parameters.Add(new SqlParameter("@UPDATED_USER", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.UPDATED_USER));
                sqlCommand.Parameters.Add(new SqlParameter("@STATUS", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.STATUS));
                sqlCommand.Parameters.Add(new SqlParameter("@REMARK", SqlDbType.Text, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.REMARK));
                sqlCommand.Parameters.Add(new SqlParameter("@COURT_APPEALS_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.COURT_APPEALS_ID));
                sqlCommand.Parameters.Add(new SqlParameter("@DECISION_TYPE_ETC", SqlDbType.NVarChar, 2147483647, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DECISION_TYPE_ETC));
                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("DCS_MASTER::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }

        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>DCS_MASTER business object</returns>
        public DCS_MASTER SelectByPrimaryKey(DCS_MASTERKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_SelectByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.MASTER_ID));

                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    DCS_MASTER businessObject = new DCS_MASTER();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return businessObject;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DCS_MASTER::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select all rescords
        /// </summary>
        /// <returns>list of DCS_MASTER</returns>
        public List<DCS_MASTER> SelectAll()
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_SelectAll]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {                
                throw new Exception("DCS_MASTER::SelectAll::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>list of DCS_MASTER</returns>
        public List<DCS_MASTER> SelectByField(string fieldName, object value)
        {

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_SelectByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));

                MainConnection.Open();
                
                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {
                throw new Exception("DCS_MASTER::SelectByField::Error occured.", ex);
            }
            finally
            {

                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Delete by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(DCS_MASTERKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_DeleteByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@MASTER_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.MASTER_ID));


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("DCS_MASTER::DeleteByKey::Error occured.", ex);
            }
            finally
            {                
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Delete records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>true for successfully deleted</returns>
        public bool DeleteByField(string fieldName, object value)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[DCS_MASTER_DeleteByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));
                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;

            }
            catch (Exception ex)
            {                
                throw new Exception("DCS_MASTER::DeleteByField::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        #endregion

        #region Private Methods

        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(DCS_MASTER businessObject, IDataReader dataReader)
        {


            businessObject.MASTER_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.MASTER_ID.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CASE_TYPE_ID.ToString())))
            {
                businessObject.CASE_TYPE_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CASE_TYPE_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.NOTICE.ToString())))
            {
                businessObject.NOTICE = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.NOTICE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CODE_NO.ToString())))
            {
                businessObject.CODE_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CODE_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATE_DECISION_DATE.ToString())))
            {
                businessObject.CREATE_DECISION_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATE_DECISION_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_TYPE_ID.ToString())))
            {
                businessObject.VOTE_TYPE_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_TYPE_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_CASE.ToString())))
            {
                businessObject.VOTE_CASE = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_CASE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COUNTY_NO.ToString())))
            {
                businessObject.COUNTY_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COUNTY_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COUNTY.ToString())))
            {
                businessObject.COUNTY = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COUNTY.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.AUMPHER.ToString())))
            {
                businessObject.AUMPHER = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.AUMPHER.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.TUMBON.ToString())))
            {
                businessObject.TUMBON = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.TUMBON.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.PROVINCE.ToString())))
            {
                businessObject.PROVINCE = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.PROVINCE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.TERM_NO.ToString())))
            {
                businessObject.TERM_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.TERM_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.DECISION_NO.ToString())))
            {
                businessObject.DECISION_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.DECISION_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CASE_NO.ToString())))
            {
                businessObject.CASE_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CASE_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_NO.ToString())))
            {
                businessObject.RESULT_NO = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_NO.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_TYPE.ToString())))
            {
                businessObject.RESULT_TYPE = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_TYPE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_TYPE_ID.ToString())))
            {
                businessObject.COURT_TYPE_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_TYPE_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_B_SUPREME_TYPE_ID.ToString())))
            {
                businessObject.COURT_B_SUPREME_TYPE_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_B_SUPREME_TYPE_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_A_SUPREME_TYPE_ID.ToString())))
            {
                businessObject.COURT_A_SUPREME_TYPE_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_A_SUPREME_TYPE_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_CONSTITU_TYPE.ToString())))
            {
                businessObject.COURT_CONSTITU_TYPE = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_CONSTITU_TYPE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.SIGN_DATE.ToString())))
            {
                businessObject.SIGN_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.SIGN_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.WARN_SIGN_DATE.ToString())))
            {
                businessObject.WARN_SIGN_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.WARN_SIGN_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_DATE.ToString())))
            {
                businessObject.VOTE_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.VOTE_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_DATE.ToString())))
            {
                businessObject.RESULT_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESULT_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.WARN_RESULT_DATE.ToString())))
            {
                businessObject.WARN_RESULT_DATE = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.WARN_RESULT_DATE.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.REQUEST_NAME.ToString())))
            {
                businessObject.REQUEST_NAME = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.REQUEST_NAME.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESPON_NAME.ToString())))
            {
                businessObject.RESPON_NAME = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.RESPON_NAME.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.ALLEGATION.ToString())))
            {
                businessObject.ALLEGATION = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.ALLEGATION.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.LAWYER_ID.ToString())))
            {
                businessObject.LAWYER_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.LAWYER_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATED_DATE_TIME.ToString())))
            {
                businessObject.CREATED_DATE_TIME = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATED_DATE_TIME.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATED_USER.ToString())))
            {
                businessObject.CREATED_USER = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.CREATED_USER.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.UPDATED_DATE_TIME.ToString())))
            {
                businessObject.UPDATED_DATE_TIME = dataReader.GetDateTime(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.UPDATED_DATE_TIME.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.UPDATED_USER.ToString())))
            {
                businessObject.UPDATED_USER = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.UPDATED_USER.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.STATUS.ToString())))
            {
                businessObject.STATUS = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.STATUS.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.REMARK.ToString())))
            {
                businessObject.REMARK = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.REMARK.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_APPEALS_ID.ToString())))
            {
                businessObject.COURT_APPEALS_ID = dataReader.GetInt32(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.COURT_APPEALS_ID.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.DECISION_TYPE_ETC.ToString())))
            {
                businessObject.DECISION_TYPE_ETC = dataReader.GetString(dataReader.GetOrdinal(DCS_MASTER.DCS_MASTERFields.DECISION_TYPE_ETC.ToString()));
            }

        }

        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of DCS_MASTER</returns>
        internal List<DCS_MASTER> PopulateObjectsFromReader(IDataReader dataReader)
        {

            List<DCS_MASTER> list = new List<DCS_MASTER>();

            while (dataReader.Read())
            {
                DCS_MASTER businessObject = new DCS_MASTER();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return list;

        }

        #endregion

	}
}
